package com.jasmine.bjstkserver.server.article;

import com.jasmine.bjstkserver.server.article.draft.model.ArticleDraftEntity;

import java.util.Optional;

/**
 * @author jasmineXz
 */
public class ArticleUtil {


    public static void paramCheck (ArticleDraftEntity draft) {
        Optional.ofNullable(draft).orElseThrow(() -> new IllegalArgumentException("未接收到文章信息"));

        if (draft.getFolderId() == null || draft.getFolderId() <=0) {
            draft.setFolderId(-1);
        }

        if (!draft.getTop().equals(ArticleConstants.TOP_YES) &&
            !draft.getTop().equals(ArticleConstants.TOP_NO)) {
            draft.setTop(null);
        }

        if (!draft.getPubState().equals(ArticleConstants.PUB_YES) &&
            !draft.getPubState().equals(ArticleConstants.PUB_NO)) {
            draft.setPubState(null);
        }
    }
}
